package game;

import java.awt.Window;

import rps.RPSClient;

import com.sun.corba.se.impl.encoding.CodeSetConversion.BTCConverter;

public class asignarTurno extends JFrameConFondo {
	
	static RPSClient gc = null;
	private javax.swing.JButton jButton1;
	private javax.swing.JButton jButton2;
	private static javax.swing.JLabel jLabel1;
	private static String personajeSel="";
	
	public asignarTurno() {
		initComponents();
	}
	
	private void initComponents() {

		jButton1 = new javax.swing.JButton();
		jLabel1 = new javax.swing.JLabel();
		jButton2 = new javax.swing.JButton();

		setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
		setTitle("Bowling Net");
		setResizable(false);

		addWindowListener(new java.awt.event.WindowAdapter() {
			public void windowClosing(java.awt.event.WindowEvent evt) {
				formWindowClosing(evt);
			}
		});
		
		jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource(
				"imagenes/loading.gif"))); // NOI18N
		jButton1.setBorder(null);
		jButton1.setBorderPainted(false);
		jButton1.setContentAreaFilled(false);

		jLabel1.setAlignmentX(50.0F);
		jLabel1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

		if (personajeSel.equals("imagenes/per1_3.png"))
			jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource(
					personajeSel))); // NOI18N		
		jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource(
				personajeSel))); // NOI18N
		jButton2.setBorder(null);
		jButton2.setBorderPainted(false);
		jButton2.setContentAreaFilled(false);

		javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
				getContentPane());
		getContentPane().setLayout(layout);
		layout
				.setHorizontalGroup(layout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								layout
										.createSequentialGroup()
										.addContainerGap(226, Short.MAX_VALUE)
										.addGroup(
												layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING)
														.addGroup(
																javax.swing.GroupLayout.Alignment.TRAILING,
																layout
																		.createSequentialGroup()
																		.addComponent(
																				jButton1)
																		.addGap(
																				325,
																				325,
																				325))
														.addGroup(
																javax.swing.GroupLayout.Alignment.TRAILING,
																layout
																		.createSequentialGroup()
																		.addComponent(
																				jLabel1)
																		.addGap(
																				186,
																				186,
																				186))))
						.addGroup(
								layout.createSequentialGroup().addGap(662, 662,
										662).addComponent(jButton2)
										.addContainerGap(47, Short.MAX_VALUE)));
		layout.setVerticalGroup(layout.createParallelGroup(
				javax.swing.GroupLayout.Alignment.LEADING).addGroup(
				layout.createSequentialGroup().addContainerGap().addComponent(
						jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 81,
						javax.swing.GroupLayout.PREFERRED_SIZE).addGap(155,
						155, 155).addComponent(jButton1).addPreferredGap(
						javax.swing.LayoutStyle.ComponentPlacement.RELATED)
						.addComponent(jLabel1).addContainerGap(181,
								Short.MAX_VALUE)));

		java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit()
				.getScreenSize();
		setBounds((screenSize.width - 800) / 2, (screenSize.height - 600) / 2,
				800, 600);
	}
	
	public static void asignaTurno(final String mensaje, final String personaje, String nick, final RPSClient client) {
		java.awt.EventQueue.invokeLater(new Runnable() {
			public void run() {				
				gc= client;				
				if(personaje.equals("imagenes/per1_3.png"))
					personajeSel="imagenes/cp1.png";
				if(personaje.equals("imagenes/per2_3.png"))
					personajeSel= "imagenes/cp2.png";
				if(personaje.equals("imagenes/per3_3.png"))
					personajeSel="imagenes/cp3.png";
				if(personaje.equals("imagenes/per4_3.png"))
					personajeSel="imagenes/cp4.png";
				JFrameConFondo jf = new asignarTurno();
				jLabel1.setText(mensaje);
				jf.setImagen("imagenes/fondoTurno.png");
				jf.setVisible(true);
			}
		});
	}
		
	private void formWindowClosing(java.awt.event.WindowEvent evt) {
		gc.salir();
	}	
		
}
